package kr.hyunist.androidcomplete02saeildamil.ch30;

import kr.hyunist.androidcomplete02saeildamil.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MusicPlayEx extends Activity {
	Button startBtn;
	Button stopBtn;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.musicplayex);
		
		startBtn = (Button) findViewById(R.id.musicplaystartbtn);
		stopBtn = (Button) findViewById(R.id.musicplaystopbtn);
		
		startBtn.setOnClickListener(mOnClickListener);
		stopBtn.setOnClickListener(mOnClickListener);
	}
	
	View.OnClickListener mOnClickListener = new View.OnClickListener() {
		Intent intent = null;
		
		@Override
		public void onClick(View v) {
			switch(v.getId()){
			case R.id.musicplaystartbtn:
				intent = new Intent(MusicPlayEx.this, MusicPlayService.class);
				startService(intent);
				break;
				
			case R.id.musicplaystopbtn:
				intent = new Intent(MusicPlayEx.this, MusicPlayService.class);
				stopService(intent);
				break;
			}
		}
		
	};
}
